<%-- 
    Document   : default
    Created on : 2009-7-11, 23:07:13
    Author     : think
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <script src="javascripts/prototype.js" language="JavaScript" type="text/javascript"></script>
        <script src="javascripts/scriptaculous.js" language="JavaScript" type="text/javascript"></script>
        <script src="javascripts/test.js" language="JavaScript" type="text/javascript"></script>
        <script src="javascripts/textboxlist.js" language="JavaScript" type="text/javascript"></script>
        <script src="javascripts/protoculous-effects-shrinkvars.js" language="JavaScript" type="text/javascript"></script>
        <script src="javascripts/rounded.js" language="JavaScript" type="text/javascript"></script>
        <link rel="stylesheet" type="text/css" media="screen" href="https://s.yimg.com/lq/i/reg/css/yregbase_sec_1.2.css">


        <style type="text/css">
            input {border: 1px solid #cccccc;}
            input.clear {border: none;}
            h2 {
                width: 50%;
                border-bottom-width: 1px;
                border-bottom-style: dotted;
                border-bottom-color: #051289;
                font-size: 130%;
                color: #666666;
                font-weight: bold;
            }
            .title{

            }
            .redblock{
                display: block;
                background-color:teal;
                background-position: 0pt -90px;
                color: #aaaaaa;
                padding-top: 2px;
                padding-right: 6px;
                padding-bottom: 2px;
                padding-left: 6px;
                height: 16px;
            }

            .note {border:2px solid #EEEEEE;
                background-color:#F9F9F9;
                float:right;
                line-height:110%;
                margin:0 15px 15px 5px;
                padding:10px;
                width:305px;
            }


            .command{
                white-space: nowrap;
                text-align: left;
                padding-right: 1em;
                background-color: #ffffff;
                background-image: none;
                background-repeat: repeat;
                background-attachment: scroll;
                background-position: 0% 0%;
                width: 20em;
                font-family: Georgia;
                color: #888888;
            }
            .error{
                color: red;
                padding-left: 1em;
            }
            .warning{
                -moz-background-clip:border;
                -moz-background-inline-policy:continuous;
                -moz-background-origin:padding;
                background-attachment:scroll;
                background-color:#DDF8CC;
                background-image:none;
                background-position:0 0;
                background-repeat:repeat;
                margin-bottom:5px;
                table-layout:fixed;
                padding: 1em;
            }
            .success{
                color: green;
                padding-left: 1em;
            }
            .data{
                background: #f2f2f2;
                padding-left: 2em;
                font-size: 90%;
            }
            .build_name{
                background-color:#EBEFF9;
                border-top:1px solid #6B90DA;
                border-bottom:1px solid #6B90DA;
                clear:both;
                padding:1.4em 0;
                -moz-background-clip:border;
                -moz-background-inline-policy:continuous;
                -moz-background-origin:padding;
                background-attachment:scroll;
                background-image:none;
                background-position:0 0;
                background-repeat:repeat;
                margin-bottom:5px;
                table-layout:fixed;
            }
            .notification{
                padding-top: 1px;
                padding-right: 13px;
                padding-bottom: 2px;
                padding-left: 7px;
                background-color: #f2f2f2;
                background-image: none;
                background-repeat: repeat;
                background-attachment: scroll;
                background-position: 0% 0%;
                background-color: #6c6c6c;
                background-image: none;
                background-repeat: repeat;
                background-attachment: scroll;
                background-position: 0% 0%;
                color: #ffffff;
                text-decoration: none;
            }
            div#header{position:relative}
            div#header h1{height:80px;line-height:80px;margin:0;
                padding-left:10px;background: #EEE;color: #79B30B}
            div#header a{position:absolute;right:0;top:23px}
            div#container{text-align:left}
            div#content p{line-height:1.4}
            div#navigation{float:left;background:#B9CAFF}
            div#footer{background: #EBEFF9;border-top:1px solid #6B90DA;}
            div#footer p{margin:10px;padding:5px}
            div#footer a{display:inline;padding:0;color: #C6D5FD}

            div#container{width:80%;margin:0 auto}
            div#content{float:left;width:65%}
            div#navigation{float:left;width:30%}
            div#footer{clear:both;width:100%}

        </style>



        <script>
            function start_RSRunner_monintor(){
                var m1 = new Ajax.PeriodicalUpdater(
                "tsrunner_state",'GetRunnerStateServlet'
                ,{method:'get',frequency:1, decay:0});
            }

            function start_jobQueue_monintor(){
                var m2 = new Ajax.PeriodicalUpdater(
                "jobqueue_state",'getQueuedJobs'
                ,{method:'get',frequency:5, decay:0});

            }

            function  start_vm_monintor(){
                new Ajax.PeriodicalUpdater(
                "vm_list","VMStateServlet",
                {method:'get',frequency:300, decay:0}
            )
            }

            function  start_cmd_result_monintor(){
                new Ajax.PeriodicalUpdater(
                "result","getCmdResults",
                {method:'get',frequency:1, decay:0}
            )
            }

            function start_notification_monitor(){
                new Ajax.PeriodicalUpdater(
                "notification", "getNotification",
                {method:'get',frequency:1, decay:0})
            }

            function setBuildName(buildName)
            {
                new Ajax.Request("setBuildName?build="+buildName,{method:'get'});
            }

            function startTSRunner(){
                new Ajax.Request("switchTSRunner?switch=on",{method:'get'});
            }

            function stopTSRunner(){
                new Ajax.Request("switchTSRunner?switch=off",{method:'get'});
            }

            function removeNotification(index){
                new Ajax.Request("removeNotification?index="+index,{method:'get'})
            }

            document.observe('dom:loaded', function() {
                start_build_name();
                start_RSRunner_monintor();
                start_runningjobs_monitor();
                start_jobQueue_monintor();
                start_vm_monintor();
                start_cmd_result_monintor();
                start_notification_monitor();
                start_recent_TS_results_monitor();
            });

            function start_build_name(){
                new Ajax.PeriodicalUpdater(
                "confirm",'getBuildName'
                ,{method:'get',frequency:5, decay:0});
            }

            function start_recent_TS_results_monitor(){
                new Ajax.PeriodicalUpdater('TS_results_list', 'recentTestResult'
                , {method:'get',frenquency:3, decay:0});
            }

            function start_runningjobs_monitor(){
                new Ajax.PeriodicalUpdater(
                "runningjob_state",'getRunningTS'
                ,{method:'get',frequency:5, decay:0});
            }

            function parseCommand(e)
            {
                var keynum
                var cmd
                if(window.event) // IE
                {
                    keynum = e.keyCode
                }
                else if(e.which) // Netscape/Firefox/Opera
                {
                    keynum = e.which
                }
                //Enter key
                if(keynum==13){
                    //alert($("command").getValue());
                    var text = $('command').getValue();
                    $('command').value = "";
                    new Ajax.Updater("result","ParseCommand?cmd="+text,{method:'get'});
                    //new Effect.Highlight('result');
                }
                //Up key
                if(keynum==38){
                }
                //Down key
                if(keynum==40){
                }
            }
        </script>
    </head>
    <body>
        <div id="container">
            <div id="notification"></div>
            <br><div id="confirm"></div><br>
            <div id="header"></div>
            <div id="content">
                <h2>Command engine status:</h2>
                <div id="tsrunner_state" ></div>
                <br>
                <h2>Running command:</h2>
                <div id="runningjob_state"></div>
                <br>
                <h2>Queued command:</h2>
                <div id="jobqueue_state"></div>
                <br>
                <h2>Online VM</h2>
                <div id="vm_list"></div>
                <br>
                <h2>Recent test results</h2>
                <div id="TS_results_list"></div>
                <br>
                <h2>Command:</h2>

                <input size="60" id="command" type="text" onkeydown="parseCommand(event)" />
                <div id="result"></div>
                <br><br>
            </div>
            <div id="extra">
                <div class="note"><h2>Welcome!</h2>
                    <div id="tips"><br><h5>Hi, this is a command drived tool for automated test across multiple VM virtual machines. Type help for brief introduction of the commands. It's still in its pre-alpha stage, hope it could get more and more useful to your test.<br><br>Have fun<br><br>Eric</h5></div>
            </div></div>
            <div id="footer"><h6><p>2009 XIAN_SUADE_QA team</p></h6></div>

        </div>
    </body>
</html>
